package Class::Value::Contact::EmailAddress;

# $Id: EmailAddress.pm 9377 2005-06-27 12:24:14Z gr $

use strict;
use warnings;
use Email::Valid;


our $VERSION = '0.02';


use base 'Class::Value::Contact';


sub is_well_formed_value {
    my ($self, $value) = @_;
    return
        $self->SUPER::is_well_formed_value($value) &&
        Email::Valid->address($value) &&
        $value =~ /^[^\@]+\@[^\@]+$/  &&      # only one '@' sign
        length($value) <= 255;
}


sub send_notify_value_not_wellformed {
    my ($self, $value) = @_;
    local $Error::Depth = $Error::Depth + 2;
    $self->exception_container->record(
        'Class::Value::Contact::Exception::Email::NotWellformed',
        email => $value,
    );
}


sub send_notify_value_invalid {
    my ($self, $value) = @_;
    local $Error::Depth = $Error::Depth + 2;
    $self->exception_container->record(
        'Class::Value::Contact::Exception::Email::Invalid',
        email => $value,
    );
}


1;


__END__

{% USE p = PodGenerated %}

=head1 NAME

{% p.package %} - contact-related value objects

=head1 SYNOPSIS

    {% p.package %}->new;

=head1 DESCRIPTION

None yet. This is an early release; fully functional, but undocumented. The
next release will have more documentation.

=head1 METHODS

=over 4

{% p.write_methods %}

=back

{% p.write_inheritance %}

{% PROCESS standard_pod %}

=cut

